package com.example.demo.mapper;

import com.example.demo.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> getUser(Integer id);

    @Insert("insert into user(username,password,phone,id_card,name,gender,birth_date,create_time,update_time,status) values(#{username},#{password},#{phone},#{idCard},#{name},#{gender},#{birthDate},#{createTime},#{updateTime},#{status})")
    void register(User user);

    @Select("select * from user where username=#{username} and password=#{password}")
    User authenticate(String username, String password);

    @Select("select * from department")
    List<Department> getAllDepartment();

    @Select("select * from doctor")
    List<Doctor> getAllDoctor();

    @Select("SELECT * FROM doctor WHERE department_id = #{departmentId}")
    List<Doctor> getDoctorsByDepartmentId(Long departmentId);

    @Select("SELECT * FROM schedule WHERE doctor_id = #{doctorId}")
    List<Schedule> getScheduleByDoctorId(Long doctorId);

    void addAppointment(Appointment appointment);

    @Update("update schedule set available_number = #{availableNumber} WHERE id = #{id}")
    void updateAvailableNumber(Schedule schedule);

    void addWaitingAppointment(Waiting waiting);

    @Select("select * from waiting")
    List<Waiting> getWaiting();


    List<AppointmentInfo> getAppointmentDetails(Long userId);

    List<WaitingDetail> getAppointmentWaiting(AppointmentInfo appointmentInfo);
}
